Author: Arnoud "Galactus" Engelfriet <galactus@htmlhelp.com>
- How do I
indent the first line in my paragraphs?
- How do I
indent a lot of text?
- Can I put
markup in ALT text?
- How do I
include one file in another?
- How do I get
scrolling text in the status bar?
- How do I
hide my source?
- How can I
make a custom rule, or a list with custom bullets?
- How do I
display the current date or time in my document?
- For what
screen size should I write?
- How do I
get my visitor's e-mail addresses?
- How do I do
a pagebreak?
- How do I
make a table which looks good on AOL and Prodigy?
- How do I
center a table?
- How do I
make animated GIFs?
- Is there a
way to get indexed better by the search engines?
- How do I
redirect someone to my new page?
- How do I
get a back button on my page?
- How do I
force a download?
- Why is my
binary file not downloaded, but shown on the screen?
- How do I
use an image instead of the standard submit button?
- How do I
get a so-and-so character in my HTML?
- How do I
get a counter?
- How do I
detect what browser is being used?
- I want to
get an audio file to play automatically when someone visits my site!
- Should I
put quotes around attribute values or not?
- Should I
use lower case or upper case for tags?
- My
images/hyperlinks are coming out all wrong, or don't load! What's up?
- How do I
get a button which takes me to a new page?
This
isn't really possible in a reliable way, until style sheets are more widely
supported. At this moment, there are several browser-specific kludges and tricks
available, but these are not guaranteed to work.
1) Use a number of ( ) characters. Netscape and related
browsers do not collapse these, like normal spaces, so this appears as an indent
in these browsers. Other browsers can display it as one space.
2) Put a <DD> at the beginning of the line. This is syntactically
invalid, but Netscape works around this by indenting the line at this point. Of
course, other browsers will handle this differently, and there is no guarantee
that Netscape will keep doing this.
3) Use a blank, transparent GIF, using WIDTH and HEIGHT to indicate the
desired whitespace. This is a very ugly solution, as it only
works if you have image loading on, otherwise you get the "Image" icon at the
beginning of the line. Not all browsers support resizing using these attributes,
and you can only "indent" a certain number of pixels, not characters. So the
amount of "indentation" varies with the font size used to display your document.
Again, there is no reliable
way to do this. Netscape will indent text inside a <BLOCKQUOTE>, but other
browsers don't have to do this. These could show the text in italics, or perhaps
with quotation marks around the text. This could come out very strange.
An
alternative is to use <DL> without <DT> and <DD>, which is
invalid HTML, but several browsers work around this error by indenting the text
inside it. This is not guaranteed to work.
If you are willing to use tables for layout purposes, there is another
option. Create a one-cell table, as follows:
<CENTER>
<TABLE width="80%">
<TR><TD><DIV align=left>
<!-- The text goes here -->
</DIV>
</TD></TR>
</TABLE>
</CENTER>
A drawback to this solution is that very long blocks inside a table may
take a while to download and may not appear until the entire table has been
downloaded. Another drawback is that it may force users to resize their viewing
window after they have become accustomed to their preferred settings.
No. Character entities
(©, &#nnn; and such) are permitted, though.
If you want to know how to write good ALT texts without markup, please see Alan Flavell's essay on choosing
ALT texts.
Use server-side
includes, if your server supports them. Ask your Webmaster if this is the case,
and if so, what the exact syntax is for your server.
Since server-side
includes make the document slower, they are not always desirable. If your
documents only have a static footer, which doesn't change every day, you might
be better off by using an editor which can insert files in the current document,
or a preprocessor. The C preprocessor can do this, but there are also several
HTML-specific preprocessors available. I recommend Orb 1.3.
This is not
an HTML question, it's done with a Javascript. Check any page which has this
feature, and copy the script from the source.
This script has two big problems. One, usually it uses the decrement operator
(c--) at some point. The "--" sequence in a comment actually closes it on some
browsers, so your code may "leak" on those browsers. The same goes for ">".
Second, keep in mind that many people consider this even worse than
<BLINK>, and that it also suppresses the status information which normally
appears there. It prevents people from knowing where a link goes to.
You can't. The source is
necessary for the browser to display your document. You have to send
the complete, unencrypted source to the browser. Even if a particular browser
doesn't have a "View source" option, there are many that do, and you can always
retrieve the document by hand (using telnet) to get its source. Or check the
browser's cache.
You can of course put a few hundred empty lines above the
actual source, then newbies who don't see the scrollbars will think there is
nothing there.
There was a proposal in the now-expired HTML 3 draft to handle
exactly this: just add SRC to the <HR> or <UL> tag, indicating where
the image can be found. But until this is more widely supported, you have to use
<IMG> for the rule, with a lot of "--" characters as ALT text for text
browsers, and using a <DL> with only <DD> tags for each item. Make
sure you use ALIGN for the image, which should go at the beginning of the item,
of course. This isn't as beautiful as a "real" list.
An alternative is using
a two column table, with the bullets in the left column, and the text in the
right. But this won't work well on non-table supporting browsers.
With server-side includes. Ask your webmaster if this is
supported, and what the exact syntax is for your server. But this will display
the local time on the server, not for the client. And if the document
is cached, the date will of course be incorrect after some time.
JavaScript
can be used to display the local time for the client, but as most people already
have one or more clocks on their screen, why display another one?
HTML does not depend
on screen size. The text will be wrapped by the browser when the end of the
screen is encountered. The only exception to this is when you use
<PRE>-formatted text, which will only wrap at the line breaks you
indicate. So make sure these lines are no longer than 70 characters, otherwise
text mode users will see ugly line breaks on their terminals. And users of
graphical browsers might have to scroll horizontally to see the rest, which is
one of the most hated things to do when you read a document.
Of course, an image cannot be wrapped, so you have to be careful with that.
It seems that 400 or 500 pixels is a reasonable width; anything above 600 will
mean a certain percentage of users will have to scroll to see the rightmost bit.
This percentage increases with your image width. Keep in mind that not everyone
runs his browser at full screen!
You can't.
Although each request for a document is usually logged with the name or address
of the remote host, the actual username is almost never logged as well. This is
mostly because of performance reasons, as it would require that the server uses
the ident protocol to see who is on the other end. This takes time. And if a
cache proxy is doing the request, you don't get anything sensible.
In
Netscape 2.0, it was possible to automatically submit a form with a mailto as
action, using Javascript. This would send e-mail to the document's owner, with
the address the visitor configured in the From line. Of course, that can be
"mickey.mouse@disney.com". This is fixed in Netscape 2.01.
The most reliable
way is to put up a form, asking the visitor to fill in his e-mail address. If
you offer him something in return, he will most likely do it.
You don't. HTML is not a page
layout language. It's up to the browser to decide where and how to insert page
breaks when the document is being printed.
However, style sheets (not widely supported yet, although Microsoft's
Internet Explorer is beginning to use it) will include support to indicate
preferred points for page breaks, probably somewhat like the way LaTeX handles
this.
The best way is probably to include a version in preformatted
text. This can be seen by any browser, including Lynx.
If you absolutely must have a table, check out Alan Flavell's document
on tables for a good discussion.
The "correct" way of doing it is
<TABLE ALIGN=CENTER>, but this doesn't work in several popular browsers.
Put <CENTER> around the entire table for these browsers.
This causes some problems with browser that do support CENTER but not tables,
such as Lynx. In these browsers, the contents of the cells is now displayed
centered, which is not what is intended. To avoid this, you can put the cell's
contents in <P ALIGN=left> or <DIV ALIGN=left> depending on the
amount of text in the cell.
Ask on the comp.infosystems.www.authoring.images
group.
Yes. Put these two statements in the <HEAD> part of your
documents: <META NAME="keywords" CONTENT="keyword keyword keyword keyword">
<META NAME="description" CONTENT="description of your site">
Both may contain up to 1022 characters. If a keyword is used more than 7
times the keywords tag will be ignored altogether. Also, you can't put markup
(other than entities) in the description or keywords list. Infoseek and Alta Vista are using this.
The most
reliable way is to configure the server to send out a redirection instruction
when the old URL is requested. Then the browser will automatically get the new
URL. This is the fastest way to do this. You can of course also simply put up a
small page with a text like "This page has moved to http://new.url/, please
adjust your bookmarks".
A Netscape-only solution, which doesn't work on other browsers, and screws up
the "back" button in Netscape, is
<META HTTP-EQUIV="Refresh" CONTENT="x; URL=new.URL">
which will load the new URL after x seconds. This should go in the HEAD of
the document. But if you do this, also include a short text saying "Document
moved to new URL so-and-so" for other browsers.
(The screwing-up bit refers to the fact that if you press "Back" after you
have been redirected, you will be taken to the document with the META refresh.
Then the refresh will be activated, and so you'll jump to the page you just
tried to leave.)
In HTML, this is
impossible. Going "back" means that you go to the previous page in your history.
You might be able to create a link to the URL specified in the "HTTP_REFERER"
environment variable in your document, but that only creates a link to a
new location in your history. Even worse, the information in that
variable can be plain wrong. Some browsers incorrectly send the
variable when you use a bookmark or type in an URL manually, and some don't send
that variable at all. Then you would end up with an empty link.
A JavaScript
could use "history.back()" to do this, but this only works in Netscape 2.
For a more detailed explanation, please see Abigail's "Simulating the
back button".
You can't. Next question,
please.
Ok, I'll explain anyway. :-) When someone downloads a document, the server
tells the browser what type of file it is. The browser then picks the
appropriate helper application, or displays it himself. If the server doesn't
know the file type, it tells the browser that the file is "text/plain", or just
plain text. You will have to ask your server admin to configure this particular
file with the MIME type you want.
"Forcing" a download is not what you are supposed to do. After all, what is
more convenient than having the proper application started when I download a
particular file? Browsing through a download directory can be quite a pain. And
most browsers allow the user to download to disk if they want to.
If the file must be saved to disk, as there is absolutely NO
other way to handle it, the MIME type should be "application/octet-stream".
Actually, the browser has downloaded the document, it
is just treating it as a plain text file. This is because the server said it
was a plain text file. To get the file in the helper application (or
plug-in), you will have to configure the server to send out the right MIME type,
and the browser to start the appropriate helper application for files with that
MIME type.
Use <INPUT NAME=foo TYPE=image
SRC="http://url.to/image.gif"> instead of the normal submit tag. There is no
way to do this for the reset button.
Note that some browsers will also send the x and y coordinates of the
location where the user clicked on the image to the server. They are available
as "foo.x=000&foo.y=000" in the CGI input.
HTML text
is supposed to be written in the ISO Latin-1 character set. A complete overview
of all the characters in this set is available from:
Either ask your Webmaster for
access to the log files, or for a server-side include which can do this, or use
one of the freeware counters available at the CGI archives. There is no HTML tag
to do this.
Counters are quite pointless, though. They can be set to any
value the owner wants, so they don't give you any information. Because of the
delay that often occurs when using an external counter, your visitors may get
annoyed with the long loading time of your document. The server's logfile
provides a lot more reliable information for you, and you don't have to bother
your readers with it.
Many browsers
identify themselves when they request a document. A CGI script will have this
information available in the HTTP_USER_AGENT environment variable, and it can
use that to send out a version of the document which is optimized for that
browser.
Keep in mind not all browsers identify themselves correctly.
Microsoft Internet Explorer, for example, claims to be "Mozilla 1.2" to get at
Netscape enhanced documents.
And of course, if a cache proxy keeps the
Netscape enhanced document, someone with an other browser will also get this
document if he goes through the cache.
Bleh. What if I visit your site at 3am, and there's
someone sleeping in the next room?
For Netscape, this is done using the <EMBED> tag. You can also do this
with the Netscape <META> refresh tag, as described earlier. Just put the
URL of the audio file in the CONTENT field.
There is also a MS Internet Explorer specific tag to do this: <BGSOUND
SRC=URL> which plays the file specified in the SRC attribute automatically.
You can add LOOP followed by a value or the keyword "INFINITE" to indicate how
many times the sound should be played.
It
depends. It is never wrong to use them, but you don't have to if the attribute
value consists only of letters, digits, periods and/or hyphens. This is
explained in the HTML
2.0 specs.
Oh, and keep in mind that if you use double quotes, you
should escape any quotes inside the value with """ so you don't
accidentally terminate the value prematurely.
Tags are
case insensitive, so it doesn't matter. This is just a matter of style. Many
people prefer upper case, as it makes the tags "stand out" better amongst the
text.
Most likely you forgot to close a quote at the end of an HREF
or SRC. Alternatively, perhaps you used a ">" character in an ALT text or
somewhere else inside a tag. Although this is legal, several older browsers will
think the tag ends there, so the rest is displayed as normal text.
This especially happens if you use comment tags to "comment out" text with
HTML tags. Although the correct
syntax is <!-- --> (without "--" occurring anywhere inside the
comment), some browsers will think the comment ends at the first > they see.
This
is done with a small form: <FORM ACTION="http://url.you.want.to.go.to/" METHOD=GET>
<INPUT TYPE=submit VALUE="Text on button" NAME=foo>
</FORM>
If you want to line up buttons next to each other, you will have to put
them in a one-row table, with each button in a separate cell.
Thanks to Warren Steel, David Henderson and William Johnston for
their comments.